﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Player : MonoBehaviour {
    public float speed = 100;

    private int count;

    public GUIText countText;

    void Start()
    {
        count = 0;
        setCountText();
    }

	void FixedUpdate () {
        float moveHorizontal = Input.GetAxis("Horizontal");
        float moveVertical = Input.GetAxis("Vertical");

        Vector3 Movement = new Vector3(moveHorizontal, 0, moveVertical);

        Rigidbody rigidbody = GetComponent<Rigidbody>();

        rigidbody.AddForce(Movement * speed * Time.deltaTime);

	}

    void OnTriggerEnter(Collider other)
    {
        if(other.gameObject.tag == "Pickup")
        {
            //other.gameObject.SetActive(false);
            Destroy(other.gameObject);
            count++;
            setCountText();
        }
    }

    void setCountText()
    {
        countText.text = "Count:" + count.ToString();
    }
}
